package com.zdj.encode;

import lombok.SneakyThrows;
import org.junit.Test;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * @author zhangdj
 * @date 2022-07-14
 */
public class Main {

    public static void main(String[] args) throws UnsupportedEncodingException {
        String s = "c2VsZWN0JTIwZGV2aWNlX2lkJTJDYWdlJTIwZnJvbSUyMHVzZXJfcHJvZmlsZSUyMG9yZGVyJTIwYnklMjBhZ2UlM0IlMEElMEFTRUxFQ1QlMjBkZXZpY2VfaWQlMkNhZ2UlMjBmcm9tJTIwdXNlcl9wcm9maWxlJTIwb3JkZXIlMjBieSUyMGFnZSUyMGRlc2MlM0I=";
        String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.name());
        System.out.println(encode);
    }

    @Test
    @SneakyThrows
    public void t1() {
        byte[] a = Base64.getDecoder().decode("c2VsZWN0JTIwZGV2aWNlX2lkJTJDYWdlJTIwZnJvbSUyMHVzZXJfcHJvZmlsZSUyMG9yZGVyJTIwYnklMjBhZ2UlM0IlMEElMEFTRUxFQ1QlMjBkZXZpY2VfaWQlMkNhZ2UlMjBmcm9tJTIwdXNlcl9wcm9maWxlJTIwb3JkZXIlMjBieSUyMGFnZSUyMGRlc2MlM0I");
        String s = new String(a);
        String decode = URLDecoder.decode(s, StandardCharsets.UTF_8.name());
        System.out.println(decode);
    }
}
